package com.itheima;

import java.time.Duration;
import java.time.LocalTime;
import java.util.Timer;
import java.util.TimerTask;

public class Test7 {
    public static void main(String[] args) {
        //定时任务对象
        Timer timer = new Timer();
        //定时任务方法

        //delay 延迟加载  1000：代表延迟一秒执行
        //period 周期，1000：每一秒执行一次
        while (true){
            LocalTime now = LocalTime.now();
            LocalTime lt = LocalTime.of(6, 30,00);
            long between = Duration.between(lt,now).getSeconds();
            if(between==0){
                timer.scheduleAtFixedRate(new TimerTask() {
                    int count=0;
                    @Override
                    public void run() {
                        count++;
                        method(count);
                    }
                },1000,1000*5*60);
                break;
            }
        }



    }

    public static void method(int count){
        System.out.println("我是一个小闹钟！！");
        if(count==10){
            System.exit(0);
        }

    }
}
